# $< stand for the first file of prerequirefiles
# $@ stand for the target files
# $^ stand for all of the prerequirefiles
# %.o:%.cpp stand for the files which replace the %.o's suffix with .cpp
# use -gstabs+ or -gdwarf-2 to get more debug info ??
export MAKEROOT := ..

BIZ_DYLIB := libimbiz.so.3
TESTTARGET := UnitTest 

vpath %.cpp ./FileTransfer/
vpath %.cpp ./FileTransfer/package/

COMMON_DEP := IMDataPack.o WWLogin.o WWNetService.o RsaCipher.o RSAWrapper.o WWBizUtility.o\
   WWCommonUtility.o	
FILETRANSFER_OBJS := P2PFileTransfer.o IMFileMessageMgr.o FtsIndirChannel.o\
	P2PPackage.o FTSPackage.o packet.o inoutpacket.o FilePacket.o filetransfer_des.o\
	CSFileTransfer.o CSFilePacket.o CSTcpChannel.o C2SPacket.o C2SHeader.o
TEST_DEP := UnitTest.o $(COMMON_DEP)
BIZ_OBJS := $(COMMON_DEP) IMContactMgr.o IMCurrentUser.o IMMsgMgr.o IMTribeMgr.o\
   SimpleBinMsgSaver.o	$(FILETRANSFER_OBJS)

export SRCFILES := $(wildcard *.cpp) $(wildcard ./FileTransfer/*.cpp)

include $(MAKEROOT)/template.mk

LDFLAGS := -lpthread -lssl -lcrypto -lz -lrt -luuid -lthreadpool -ljsoncpp $(LDFLAGS)
BIZ_OBJS_PATH := $(BIZ_OBJS:%.o=$(OBJDIR)/%.o)
TEST_DEP_PATH := $(TEST_DEP:%.o=$(OBJDIR)/%.o)
TESTTARGETPATH := $(BINDIR)/$(TESTTARGET)
BIZTARGET_PATH := $(BINDIR)/$(BIZ_DYLIB)

all: $(BIZTARGET_PATH) $(TESTTARGETPATH) 

$(BIZTARGET_PATH): $(BIZ_OBJS_PATH) 
	$(CC) $(SHARED) -o $@ $^ $(LDFLAGS) -lmsgbusclient -lprotocol -lIMMsgBusParam 

$(TESTTARGETPATH): $(TEST_DEP_PATH) 
	$(CC) -o $@ $^ $(LDFLAGS)  -lmsgbusclient  -lprotocol 

clean:
	-rm -f *.d ./FileTransfer/*.d ./FileTransfer/package/*.d $(TESTTARGETPATH) $(TEST_DEP_PATH) $(BIZTARGET_PATH) $(BIZ_OBJS_PATH)

cleantest:
	-rm -f  $(TESTTARGETPATH) $(TEST_DEP_PATH) 

